import random

# 星座日期范围
constellations = [
    ("白羊座", (3, 21), (4, 19)),
    ("金牛座", (4, 20), (5, 20)),
    ("双子座", (5, 21), (6, 21)),
    ("巨蟹座", (6, 22), (7, 22)),
    ("狮子座", (7, 23), (8, 22)),
    ("处女座", (8, 23), (9, 22)),
    ("天秤座", (9, 23), (10, 23)),
    ("天蝎座", (10, 24), (11, 22)),
    ("射手座", (11, 23), (12, 21)),
    ("摩羯座", (12, 22), (1, 19)),
    ("水瓶座", (1, 20), (2, 18)),
    ("双鱼座", (2, 19), (3, 20))
]

# 星体列表
planets = ["太阳", "月亮", "水星", "金星", "火星"]

# 简单的星体在星座的解读字典
interpretations = {
    ("太阳", "白羊座"): "太阳在白羊座赋予你强烈的个人意志和领导能力，你勇敢无畏，喜欢追求新的挑战。",
    ("太阳", "金牛座"): "太阳位于金牛座使你具有稳定和坚持的特质，对待目标会一步一个脚印地前进。",
    # 可以继续添加更多星体 - 星座组合的解读
}


# 根据出生日期确定星座
def get_constellation(month, day):
    for constellation, start, end in constellations:
        if (month, day) >= start and (month, day) <= end:
            return constellation
    # 处理摩羯座跨年的特殊情况
    if (month == 1 and day <= 19) or (month == 12 and day >= 22):
        return "摩羯座"


# 生成星盘
def generate_astrological_chart(constellation):
    chart = {}
    for planet in planets:
        # 这里简单模拟星体大部分落在用户星座，也有小概率落在其他星座
        if random.random() < 0.7:
            chart[planet] = constellation
        else:
            other_constellations = [c[0] for c in constellations if c[0] != constellation]
            chart[planet] = random.choice(other_constellations)
    return chart


# 显示星盘及解读
def show_astrological_chart(chart):
    print("你的星座星盘如下：")
    for planet, constellation in chart.items():
        print(f"{planet} 位于 {constellation}")
        key = (planet, constellation)
        if key in interpretations:
            print(f"    解读: {interpretations[key]}")
        else:
            print(f"    暂无 {planet} 在 {constellation} 的解读信息。")


# 主游戏函数
def astrological_game():
    print("欢迎来到星座星盘游戏！")
    try:
        month = int(input("请输入你的出生月份 (1 - 12): "))
        day = int(input("请输入你的出生日期 (1 - 31): "))
        constellation = get_constellation(month, day)
        print(f"你的星座是 {constellation}")
        chart = generate_astrological_chart(constellation)
        show_astrological_chart(chart)
    except ValueError:
        print("输入无效，请输入有效的数字。")
    print("游戏结束，感谢参与！")


if __name__ == "__main__":
    astrological_game()